<?php

namespace App\Http\Controllers\Plugin;


use App\Helpers\ResponseData;
use Illuminate\Http\Request;
class UploadImageController
{

    use OssController,ResponseData;
    //单图上传
    public function upload(Request $request){
        if ($request->hasFile('file') && $request->file('file')->isValid()) {
            $path = $this->commonUpload($request->file('file'));
            return $this->success($path);
        }else{
            return $this->failed($request->all(),201);
        }
    }
    //多图上传
    public function multiImgs(Request $request){
        if ($request->hasFile('file') && $request->file('file')->isValid()) {
            foreach($request->hasFile('file') as $item){
                $path[] = $this->commonUpload($item);
            }
            return $this->success($path);
        }else{
            return $this->failed($request->all(),201);
        }
    }
}
